package com.yidu.finance.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebFilter;

/**
 * Servlet Filter implementation class KeyWordFilter
 */
@MultipartConfig
@WebFilter("/MemberServlet")
public class KeyWordFilter implements Filter {

     
	String keyWord = "邓小平,毛泽东,昊涛,睡觉,法轮功,风袖,氵去---车仑---工力";

	/**
	 * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
	 */
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		
		String memberName = request.getParameter("memberName");
		System.out.println("接收到的名字是:"+memberName);
		if(memberName!= null && keyWord.indexOf(memberName)>-1){
			request.setAttribute("msg", "不能使用敏感关键字!");
			request.getRequestDispatcher("pages/member/regist.jsp").forward(request, response);
			return ;
		}
		
		
		chain.doFilter(request, response);
	}

	 
}
